﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine.UI;
using ZZQFrameWork;

public class EquipItem:MonoBehaviour
{
    private EquipInfoPanel equipInfoPanel;

    public Enum_SubGoodsType equipItemType = Enum_SubGoodsType.None;
    private Image equipIconImage;
    private Image frameImage;
    private GoodsVO data;

    public GoodsVO Data
    {
        get { return data; }
        set { data = value;
            UpdateShow();
        }
    }

    void Awake()
    {
        equipIconImage = transform.GetComponentByPath<Image>("EquipIcon");
        frameImage = transform.GetComponentByPath<Image>("Frame");
    }

    void UpdateShow()
    {
        if (Data == null)
        {
            equipIconImage.gameObject.SetActive(false);
        }
        else
        {
            //Debug.Log("需要更新装备显示，装备槽类型：" + equipItemType + "装备类型：" + Data.subGoodsType);
            equipIconImage.gameObject.SetActive(true);
            equipIconImage.sprite = equipInfoPanel.EquipAtlas.GetSprite(Data.icon);
        }
    }

    public void SetEquipInfoPanel(EquipInfoPanel panel)
    {
        equipInfoPanel = panel;
    }

    public void SetItemClicked(bool clicked)
    {
        frameImage.gameObject.SetActive(clicked);
    }

    /// <summary>
    /// 指引装备，当背包中选择了该类型的装备时，会提示可以装备到该装备栏
    /// </summary>
    public void GuideEquip(bool guide)
    {
        frameImage.gameObject.SetActive(guide);
    }
}

